import { Router } from 'express';
import { NavigationController } from '../../api/controllers/navigationController';
import { authenticateClient } from '../../middleware/auth';
import { logOperation } from '../../middleware/operationLog';

const router = Router();
const navigationController = new NavigationController();

/**
 * @swagger
 * /api/client/navigation/map:
 *   get:
 *     summary: 获取场地地图
 *     tags: [Navigation]
 *     parameters:
 *       - in: query
 *         name: floor
 *         schema:
 *           type: string
 *         description: 楼层
 *     responses:
 *       200:
 *         description: 成功获取场地地图
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 message:
 *                   type: string
 *                   example: 获取场地地图成功
 *                 data:
 *                   type: object
 *                   properties:
 *                     floors:
 *                       type: array
 *                       items:
 *                         type: object
 *                         properties:
 *                           id:
 *                             type: integer
 *                             description: 楼层ID
 *                           venue:
 *                             type: string
 *                             description: 场地名称
 *                           name:
 *                             type: string
 *                             description: 楼层名称
 *                           level:
 *                             type: integer
 *                             description: 楼层级别
 *                           description:
 *                             type: string
 *                             description: 楼层描述
 *                           status:
 *                             type: string
 *                             enum: [ACTIVE, INACTIVE]
 *                             description: 楼层状态
 *                     message:
 *                       type: string
 *                       description: 提示信息
 */
router.get('/map', authenticateClient, navigationController.getMap);

/**
 * @swagger
 * /api/client/navigation/location:
 *   get:
 *     summary: 获取用户当前位置
 *     tags: [Navigation]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功获取用户位置
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 message:
 *                   type: string
 *                   example: 获取用户位置成功
 *                 data:
 *                   $ref: '#/components/schemas/UserLocation'
 */
router.get('/location', authenticateClient, navigationController.getUserLocation);

/**
 * @swagger
 * /api/client/navigation/location:
 *   post:
 *     summary: 更新用户位置
 *     tags: [Navigation]
 *     security:
 *       - bearerAuth: []
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required:
 *               - latitude
 *               - longitude
 *             properties:
 *               latitude:
 *                 type: number
 *                 description: 纬度
 *                 minimum: -90
 *                 maximum: 90
 *               longitude:
 *                 type: number
 *                 description: 经度
 *                 minimum: -180
 *                 maximum: 180
 *               floor:
 *                 type: string
 *                 description: 楼层
 *               accuracy:
 *                 type: number
 *                 description: 精度
 *     responses:
 *       200:
 *         description: 成功更新用户位置
 */
router.post('/location', authenticateClient, logOperation('update', 'user_location'), navigationController.updateUserLocation);

/**
 * @swagger
 * /api/client/navigation/route:
 *   get:
 *     summary: 获取导航路线
 *     tags: [Navigation]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: query
 *         name: from
 *         required: true
 *         schema:
 *           type: string
 *         description: 起点位置
 *       - in: query
 *         name: to
 *         required: true
 *         schema:
 *           type: string
 *         description: 终点位置
 *     responses:
 *       200:
 *         description: 成功获取导航路线
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 message:
 *                   type: string
 *                   example: 获取导航路线成功
 *                 data:
 *                   type: object
 *                   properties:
 *                     from:
 *                       type: string
 *                       description: 起点位置
 *                     to:
 *                       type: string
 *                       description: 终点位置
 *                     distance:
 *                       type: number
 *                       description: 距离（米）
 *                     estimatedTime:
 *                       type: number
 *                       description: 预计时间（分钟）
 *                     steps:
 *                       type: array
 *                       items:
 *                         type: object
 *                         properties:
 *                           type:
 *                             type: string
 *                             enum: [start, navigate, end]
 *                           description:
 *                             type: string
 *                           distance:
 *                             type: string
 */
router.get('/route', authenticateClient, navigationController.getRoute);

export default router; 